package com.tanhua.dubbo.api.mongo;

import com.tanhua.domain.mongo.Voice;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

import java.util.List;

@Service
public class peachblossomApiImpl implements PeachblossomApi{
    @Autowired
    private MongoTemplate mongoTemplate;
    @Override
    public void saveVoice(String url, Long userId) {
        Voice voice = new Voice();
        voice.setCreated(System.currentTimeMillis());
        voice.setUserId(userId);
        voice.setSoundUrl(url);
        mongoTemplate.insert(voice);
    }

    @Override
    public List<Voice> findAllVoice() {
        List<Voice> voices = mongoTemplate.findAll(Voice.class);
        return voices;
    }
}
